#include<iostream>
#include<set>
#include<map>
#include<string>
#include<cctype>
using namespace std;
void practice_11_3();
void practice_11_4();
int main()
{
	//practice_11_3();
	practice_11_4();
	return 0;
}
void practice_11_3()
{
	map<string,size_t> word_count;
	string word;
	while(cin>>word)
	{
		++word_count[word];
	}
	for(const pair<string,size_t> &p:word_count){
		cout<<p.first<<" "<<p.second<<endl;
	}
}
void practice_11_4()
{
	map<string,size_t> word_count;
	set<char> suffix{',','.'};
	string word;
	while(cin>>word)
	{
		if(!(suffix.find(*(word.cend()-1))==suffix.end()))
			word.erase(word.size()-1,1);
		if(isupper(*(word.begin()))){
			string temp="";
			char c=static_cast<char>(tolower(*(word.begin())));
			word.replace(0,1,temp+c);
		}
		++word_count[word];
	}
	for(const pair<string,size_t> &p:word_count)
		cout<<p.first<<" "<<p.second<<endl;
}